import {Input, message} from "antd";
import {useState} from "react";

export default function ({
                           value
                           , onChange
                           , onBlur
                           , ...props
                         }) {
  const [valueStr, setValueStr] = useState(JSON.stringify(value))

  return <Input.TextArea
    {...props}
    value={valueStr}
    onChange={e => {
      setValueStr(e.target.value)
    }}
    onBlur={e=>{
      try {
        onBlur && onBlur(JSON.parse(e.target.value))
      } catch (e) {
        message.warning('JSON格式不正确')
      }
    }}
  />
}